import { clickButtonOrRect } from "./utils"

/**
 * 管理机
 */
import "reflect-metadata";
/**
 * 引入公共文件
 */
import "./common";
/**
 * 管理机的主要职责是 管理本脚本下的所有任务
 * 1. 管理UI任务
 * 2. 管理脚本任务
 * 3. 务必轻量
 */
import { container as injector } from 'tsyringe'
import { Sender } from "./autox/sender";
import { Timer } from "./autox/timer";

const sender = injector.resolve(Sender)
const timer = injector.resolve(Timer)
timer.setInterval(() => { }, 1000 * 10)
sender.on('DOWNLOAD_FROM_URL', (payload: any) => {
    toLiveRoom(payload.url)
})
function toLiveRoom(url: string) {
    setClip(url)
    app.launchPackage('com.kuaishou.nebula')
    textContains('进入直播间').waitFor()
    sleep(random(2000, 3000))
    clickButtonOrRect(textContains('进入直播间').findOne())
}
